package top.lyc829.zzl_android.ui.profile.user_fans;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.google.android.material.tabs.TabLayoutMediator;

import top.lyc829.zzl_android.R;
import top.lyc829.zzl_android.databinding.ActivityFansBinding;
import top.lyc829.zzl_android.databinding.ActivityFollowBinding;
import top.lyc829.zzl_android.logic.bean.UserInfoBean;
import top.lyc829.zzl_android.logic.util.Utils;
import top.lyc829.zzl_android.ui.profile.follow.base.FollowBaseFragment;
import top.lyc829.zzl_android.ui.profile.follow.team.FollowTeamFragment;
import top.lyc829.zzl_android.ui.profile.follow.user.FollowUserFragment;
import top.lyc829.zzl_android.ui.profile.follow.user_detail.OtherUserDetailActivity;

public class FansActivity extends AppCompatActivity {

    ActivityFansBinding binding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityFansBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

// 点击返回箭头返回上一页
        binding.mTitleBarFans.setLeftClickListener(v -> finish());

        int userId=getIntent().getIntExtra("id",-1);

        ViewPager2 viewPager2 = binding.viewPager2;
        viewPager2.setAdapter(new FragmentStateAdapter(this) {
            @NonNull
            @Override
            public Fragment createFragment(int position) {

                UserFansFragment fragment1=new UserFansFragment();
                fragment1.setOtherUserId(userId);
                    return fragment1;
            }

            @Override
            public int getItemCount() {
                return 1;
            }
        });

        int pid=Utils.getUserId();
        TabLayoutMediator mediator = new TabLayoutMediator(binding.tabLayout, viewPager2, ((tab, position) -> {
            if (position == 0) {
                if(userId!=pid) {
                    tab.setText("Ta的粉丝");
                }
                else
                {
                    tab.setText("我的粉丝");
                }
            }
        }));

        mediator.attach();
    }


}